﻿using BCCommon;
using BCDto.TMS.VehicleTransportFaq;
using BCService.TMS.VehicleTransportFaq;
using BCTMSRESTful.Configs;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace BCTMSRESTful.Controllers.Management.TMS.VehicleTransportFaq
{
    /// <summary>
    /// 车辆运输问题接口
    /// </summary> 
    [ApiExplorerSettings(GroupName = "TMSAdmin")]
    [Route("api/v1/sim/[controller]")]
    public class VehicleTransportFaqController : ManagementBaseController
    {
        #region var
        private IVehicleTransportFaqService vehicleTransportFaqService;
        #endregion


        #region 构造函数
        /// <summary>
        /// 构造函数
        /// </summary> 
        public VehicleTransportFaqController(IVehicleTransportFaqService vehicleTransportFaqService)
        {
            this.vehicleTransportFaqService = vehicleTransportFaqService;
        }
        #endregion

        #region POST 添加  
        /// <summary>
        /// 添加新车辆运输问题纪录
        /// </summary>
        /// <param name="dto">车辆运输问题数据模型</param>
        /// <returns></returns>
        [Log("添加新车辆运输问题纪录")]
        [HttpPost]
        [ProducesResponseType(typeof(VehicleTransportFaqRequestDto), 200)]
        public IActionResult Post([FromBody] VehicleTransportFaqRequestDto dto)
        {
            var a = vehicleTransportFaqService.Add(dto, this.Admin);
            return Ok(a);
        }

        #endregion

        #region PUT 修改   
        /// <summary>
        /// 修改车辆运输问题纪录
        /// </summary>
        /// <param name="dto">车辆运输问题数据模型</param>
        /// <returns></returns>
        [Log("修改车辆运输问题纪录")]
        [HttpPut]
        [ProducesResponseType(typeof(VehicleTransportFaqDto), 200)]
        public IActionResult Put([FromBody] VehicleTransportFaqDto dto)
        {
            var a = Ok(vehicleTransportFaqService.Update(dto, this.Admin));
            return a;
        }
        #endregion

        #region 删除  
        /// <summary>
        /// 删除车辆运输问题纪录
        /// </summary>
        /// <param name="vehicleTransportFaqId">车辆运输问题ID</param>
        /// <returns></returns>
        [Log("删除车辆运输问题纪录")]
        [HttpDelete("{vehicle_transport_faq_id}")]
        [ProducesResponseType(typeof(NoContentResult), 204)]
        public IActionResult Delete([FromRoute(Name = "vehicle_transport_faq_id")] long vehicleTransportFaqId)
        {
            vehicleTransportFaqService.Delete(vehicleTransportFaqId);
            return NoContent();
        }
        #endregion

        #region GetByID     
        /// <summary>
        /// 获取一条车辆运输问题纪录
        /// </summary>
        /// <param name="vehicleTransportFaqId">车辆运输问题ID</param>
        /// <returns></returns>
        [HttpGet("{vehicle_transport_faq_id}")]
        [ProducesResponseType(typeof(VehicleTransportFaqDto), 200)]
        public IActionResult Get([FromRoute(Name = "vehicle_transport_faq_id")] long vehicleTransportFaqId)
        {
            return (Ok(vehicleTransportFaqService.GetById(vehicleTransportFaqId)));

        }
        #endregion

        #region Query 查询车辆运输问题
        /// <summary>
        /// 查询车辆运输问题
        /// </summary>
        /// <param name="faqCategoryId">车辆运输问题分类Id</param>
        /// <param name="title">常见问题标题</param>
        /// <param name="question">常见问题描述</param>
        /// <param name="answer">常见问题回复</param>
        /// <param name="keyWord">关键字</param>
        /// <param name="isShow">是否显示</param>
        /// <param name="isDelete">是否已删除</param>
        /// <param name="isReply">是否已回复</param>
        /// <param name="isSolve">是否已解决</param>
        /// <param name="enable">已启用</param>
        /// <param name="start">创建时间</param>
        /// <param name="end">创建时间</param>
        /// <param name="replyEmail">回复邮箱</param>
        /// <param name="sortName">排序字段</param>
        /// <param name="ascending">升序</param>
        /// <param name="pageIndex">页码</param>
        /// <param name="pageSize">页大小</param>
        /// <returns></returns>
        [HttpGet("[action]")]
        [ProducesResponseType(typeof(PageableList<VehicleTransportFaqDto>), 200)]
        public IActionResult Query(
           [FromQuery(Name = "vehicle_transport_faq_category_id")] int? faqCategoryId,
           [FromQuery(Name = "title")] string title,
           [FromQuery(Name = "question")] string question,
           [FromQuery(Name = "answer")] string answer,
           [FromQuery(Name = "key_word")] string keyWord,
           [FromQuery(Name = "is_show")] bool? isShow,
           [FromQuery(Name = "is_delete")] bool? isDelete,
           [FromQuery(Name = "is_reply")] bool? isReply,
           [FromQuery(Name = "is_solve")] bool? isSolve,
           [FromQuery(Name = "enable")] bool? enable,
           [FromQuery(Name = "start")] DateTime? start,
           [FromQuery(Name = "end")] DateTime? end,
           [FromQuery(Name = "reply_email")] string replyEmail,
            [FromQuery(Name = "sort_name")] string sortName,
            [FromQuery(Name = "ascending")] bool? ascending,
            [FromQuery(Name = "index")] int? pageIndex = 1,
            [FromQuery(Name = "size")] int? pageSize = 10)
        {
            var a = Ok(vehicleTransportFaqService.GetList(faqCategoryId, title, question, answer, keyWord, isShow, isDelete, isReply, isSolve, enable, start, end, replyEmail, sortName, ascending, pageIndex.Value, pageSize.Value));
            return a;
        }
        #endregion


        #region 更新 回复信息 
        /// <summary>
        /// 更新 回复信息 
        /// </summary>
        /// <param name="vehicleTransportFaqId">车辆运输问题ID</param>
        /// <param name="answer">常见问题回复</param>
        /// <param name="keyWord">关键字</param>
        /// <param name="isSolve">是否已解决</param>
        /// <returns></returns>
        [HttpGet("[action]")]
        [ProducesResponseType(typeof(VehicleTransportFaqDto), 200)]
        [Log("修改车辆运输问题纪录回复信息 ")]
        public IActionResult UpdateAnswer(
            [FromQuery(Name = "vehicle_transport_faq_id")] long vehicleTransportFaqId,
           [FromQuery(Name = "answer")] string answer,
           [FromQuery(Name = "key_word")] string keyWord,
           [FromQuery(Name = "is_solve")] bool? isSolve)
        {
            return (Ok(vehicleTransportFaqService.UpdateAnswer(vehicleTransportFaqId,answer,keyWord,isSolve,Admin)));
        }
        #endregion

        #region 修改 记录状态
        /// <summary>
        /// 修改 记录状态
        /// </summary>
        /// <param name="vehicleTransportFaqId">车辆运输问题ID</param>
        /// <param name="isShow">是否显示</param>
        /// <param name="isDelete">是否已删除</param>
        /// <param name="isReply">是否已回复</param>
        /// <param name="isSolve">是否已解决</param>
        /// <param name="enable">已启用</param>
        /// <returns></returns>
        [HttpGet("[action]")]
        [ProducesResponseType(typeof(VehicleTransportFaqDto), 200)]
        [Log("修改车辆运输问题纪录状态")]
        public IActionResult UpdateStatus(
            [FromQuery(Name = "vehicle_transport_faq_id")] long vehicleTransportFaqId,
           [FromQuery(Name = "is_show")] bool? isShow,
           [FromQuery(Name = "is_delete")] bool? isDelete,
           [FromQuery(Name = "is_reply")] bool? isReply,
           [FromQuery(Name = "is_solve")] bool? isSolve,
           [FromQuery(Name = "enable")] bool? enable)
        {
            return Ok(vehicleTransportFaqService.UpdateStatus(vehicleTransportFaqId, isShow, isReply, isSolve, enable, isDelete));
        }
        #endregion



        #region 修改车辆运输问题纪录状态
        /// <summary>
        /// 修改车辆运输问题纪录状态
        /// </summary>
        /// <param name="vehicleTransportFaqStatusPutDto">车辆运输问题状态修改模型</param>
        /// <returns></returns>
        [HttpPut("[action]")]
        [ProducesResponseType(typeof(VehicleTransportFaqDto), 200)]
        [Log("修改车辆运输问题纪录状态")]
        public IActionResult UpdateIsShow([FromBody]VehicleTransportFaqStatusPutDto vehicleTransportFaqStatusPutDto)
        {
            return Ok(vehicleTransportFaqService.UpdateStatus(vehicleTransportFaqStatusPutDto));
        }
        #endregion
         
    }

}
